﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using qiupeng.Public;
using System.IO;
public partial class SystemManage_username_add : Base
{
    Db List = new Db();
    BindDrowDownList list = new BindDrowDownList();
    public static string fjkey;

    protected void Page_Load(object sender, EventArgs e)
    {


        if (!Page.IsPostBack)
        {
            BindAttribute();
        }
    }
    public void BindAttribute()
    {
        Respon.Attributes.Add("readonly", "readonly");

        StaffNumer.Attributes.Add("readonly", "readonly");
        XingMing.Attributes.Add("readonly", "readonly");
        XingBie.Attributes.Add("readonly", "readonly");
        ShenFen.Attributes.Add("readonly", "readonly");
        BuMen.Attributes.Add("readonly", "readonly");
        zhiweileibie.Attributes.Add("readonly", "readonly");

        //Button2.Attributes["onclick"] = "javascript:return showwait();";
        Button1.Attributes["onclick"] = "javascript:return chknull();";
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("username.aspx");
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string str = FormsAuthentication.HashPasswordForStoringInConfigFile(this.Password.Text, "MD5");
        string sql = "select * from qp_hr_Username where Username='" + this.List.GetFormatStr(this.Username.Text) + "'";
        OleDbDataReader list = this.List.GetList(sql);
        if (list.Read())
        {
            base.Response.Write("<script language=javascript>alert('用户名重复！');</script>");
        }
        else
        {
            list.Close();
            string str3 = null;
            string str4 = "select * from qp_hr_Respon where id='" + this.ResponId.Text + "'";
            OleDbDataReader reader2 = this.List.GetList(str4);
            if (reader2.Read())
            {
                str3 = reader2["Perstr"].ToString();
            }
            reader2.Close();
            string str5 = "insert into qp_hr_MyReminded (Sound,iftx,txtime,Username,Realname) values ('1.swf','是','300000','" + this.List.GetFormatStr(this.Username.Text) + "','" + this.List.GetFormatStr(this.XingMing.Text) + "')";
            this.List.ExeSql(str5);
            string str6 = "insert into qp_hr_username (Realname,StaffId,StaffNumer,XingMing,XingBie,ShenFen,BuMenId,BuMen,GangWei,ZhiWu,Username,Password,Respon,ResponId,ResponQx,Iflogin,Remark,settime,ResponRemark) select '" + this.List.GetFormatStr(this.XingMing.Text) + "','" + this.List.GetFormatStr(this.StaffId.Text) + "','" + this.List.GetFormatStr(this.StaffNumer.Text) + "','" + this.List.GetFormatStr(this.XingMing.Text) + "','" + this.List.GetFormatStr(this.XingBie.Text) + "','" + this.List.GetFormatStr(this.ShenFen.Text) + "','" + this.List.GetFormatStr(this.BuMenId.Text) + "','" + this.List.GetFormatStr(this.BuMen.Text) + "','','','" + this.List.GetFormatStr(this.Username.Text) + "','" + str + "','" + this.List.GetFormatStr(base.Request.Form["Respon"]) + "','" + this.List.GetFormatStr(this.ResponId.Text) + "','" + str3 + "','" + this.List.GetFormatStr(this.Iflogin.SelectedValue) + "','" + this.List.GetFormatStr(this.Remark.Text) + "','" + DateTime.Now.ToString() + "',TestUser from qp_hr_Respon where id=" + this.List.GetFormatStr(this.ResponId.Text);
            this.List.ExeSql(str6);
            this.List.InsertLog("新增系统用户[" + this.Username.Text + "]", "用户信息");
            base.Response.Write("<script language=javascript>alert('提交成功！');window.opener.location.reload();window.close();</script>");
        }

    }
}
